//
// Created by ole on 24-8-17.
//

#include <sstream>
#include "Message.h"

std::string Message::getAction() const {
    return action;
}

void Message::setAction(const std::string &action) {
    this->action = action;
}

std::string Message::getCategory() const {
    return category;
}

void Message::setCategory(const std::string &category) {
    this->category = category;
}

std::string Message::getData() const {
    return data;
}

void Message::setData(const std::string &data) {
    this->data = data;
}

int Message::getFlag() const {
    return flag;
}

void Message::setFlag(const int &flag) {
    this->flag = flag;
}

void Message::putString(const std::string &key, const std::string &value) {
    mapString[key] = value;
}

void Message::removeString(const std::string &key) {
    mapString.erase(key);
}

void Message::putInt(const std::string &key, const int &value) {
    mapInt[key] = value;
}

void Message::removeInt(const std::string &key) {
    mapInt.erase(key);
}

std::string Message::toString() const {
    std::stringstream ss;
    ss << "Intent{";
    ss << "action='" << action << "', ";
    ss << "category='" << category << "', ";
    ss << "priority='" << priority << "', ";
    ss << "data='" << data << "', ";
    ss << "flag=" << flag << ", ";

    ss << "mapString={";
    for (const auto &pair: mapString) {
        ss << pair.first << "=" << pair.second << " ";
    }
    ss << "}, ";

    ss << "mapInt={";
    for (const auto &pair: mapInt) {
        ss << pair.first << "=" << pair.second << " ";
    }
    ss << "}}";

    return ss.str();
}
